package com.coffee.job.service.quartz.job;


import com.coffee.core.util.DateUtil;
import com.coffee.order.api.inquire.service.InquireOrderService;
import com.coffee.order.api.sku.service.SkuOrderService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;

import javax.annotation.Nonnull;
import java.util.Date;


@DisallowConcurrentExecution
public class SkuCancelWaitingOrderJob extends QuartzJobBean {
    private static final Logger logger = LoggerFactory.getLogger(SkuCancelWaitingOrderJob.class);

    @DubboReference(check = false)
    private SkuOrderService skuOrderService;

    @Override
    protected void executeInternal(@Nonnull JobExecutionContext context) {
        logger.info("==========SkuCancelWaitingOrderJob开始：" + DateUtil.getDateTime(new Date(), DateUtil.DEFAULT_DATETIME_FORMAT));
        try {
            skuOrderService.cancelWaitingOrder();
            logger.info("==========SkuCancelWaitingOrderJob结束：" + DateUtil.getDateTime(new Date(), DateUtil.DEFAULT_DATETIME_FORMAT));
        } catch (Exception e) {
            logger.info("==========SkuCancelWaitingOrderJob失败==========", e);
        }
    }

}
